home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ispell40.lha / ispell-4.0 / ispell.c < prev    next >
C/C++ Source or Header  |  1993-05-31  |  28KB  |  910 lines

  1. /* Copyright (C) 1990, 1993  Free Software Foundation, Inc.
  2.  
  3.    This file is part of GNU ISPELL.
  4.    
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* ISPELL is an interactive spelling corrector generates a list
  20.    of near misses for each misspelled word.  The direct parantage
  21.    of this version seems to have begun in California in the
  22.    early 70's.  A child of that version was known as SPELL on
  23.    the MIT ITS systems, and later ISPELL on MIT TOPS-20 systems.
  24.    I wrote the first C implementation in 1983, and then developed
  25.    this version in 1988.  See the History section of ispell.texinfo
  26.    for more information.
  27.  
  28.    Pace Willisson
  29.    pace@ai.mit.edu  pace@hx.lcs.mit.edu
  30.    (617) 625-3452
  31.  
  32.    See ChangeLog for further author information. */
  33.  
  34. #include <stdio.h>
  35. #include <ctype.h>
  36. #include <signal.h>
  37.  
  38. #ifdef HAVE_MALLOC_H
  39. #include <malloc.h>
  40. #endif
  41.  
  42. #include "getopt.h"
  43.  
  44. #include "ispell.h"
  45. #include "hash.h"
  46. #include "charset.h"
  47.  
  48. static void show_warranty (NOARGS);
  49. static void show_copying (NOARGS);
  50. static void show_signon (NOARGS);
  51.  
  52. char **lexdecode = NULL;
  53.  
  54. /* this array contains letters to use when generating near misses */
  55. char near_miss_letters[256];
  56. int nnear_miss_letters;
  57.  
  58. /* this array has 1 for any character that is in near_miss_letters */
  59. char near_map[256];
  60.  
  61. enum formatter formatter;
  62.  
  63. /* set to 1 if any interaction takes place */
  64. int interaction_flag = 1;
  65.  
  66. int lflag;
  67. int aflag;
  68. int dflag;
  69. int pflag;
  70. int Sflag;
  71. int askflag;
  72. int Dflag;
  73. int Eflag;
  74. int hflag;
  75. int uflag;
  76. int iflag;
  77. char *dname;
  78. char *privname;
  79. int intr_typed;
  80.  
  81. FILE *sortf;
  82.  
  83.  
  84. void
  85. usage ()
  86. {
  87.   (void) fprintf (stderr, "Usage: ispell [-d dict] [-p privdict] file\n");
  88.   (void) fprintf (stderr, "or:    ispell [-a | -l]\n");
  89.   exit (1);
  90. }
  91.  
  92.  
  93. RETSIGTYPE
  94. intr ()
  95. {
  96.   signal (SIGINT, (RETSIGTYPE (*)()) intr);
  97.   intr_typed = 1;
  98. }
  99.  
  100.  
  101. void
  102. done ()
  103. {
  104.   extern char tempfile[];
  105.  
  106.   if (tempfile[0])
  107.     {
  108.       (void) unlink (tempfile);
  109.       tempfile[0] = 0;
  110.     }
  111.   termuninit ();
  112.   exit (0);
  113. }
  114.  
  115.  
  116. int
  117. main (argc, argv)
  118.   int argc;
  119.   char **argv;
  120. {
  121.   int c;
  122.   extern char *optarg;
  123.   extern int optind;
  124.   char *p;
  125.   int i;
  126.  
  127.   for (i = 0; i < 256; i++)
  128.     if (charset[i].word_component)
  129.       (ctbl + 1)[i] |= LEXLETTER;
  130.  
  131.   /* if invoked by the name 'spell', set uflag */
  132.   if ((p = (char *) strrchr (argv[0], '/')))
  133.     p++;
  134.   else
  135.     p = argv[0];
  136.  
  137.   if (strcmp (p, "spell") == 0)
  138.     {
  139.       uflag = 1;
  140.       lflag = 1;
  141.     }
  142.  
  143.   formatter = formatter_generic;
  144.  
  145.   while ((c = getopt (argc, argv, "alp:d:SDEhuvbixtWC")) != EOF)
  146.     {
  147.       switch (c)
  148.     {
  149.     case 'W':
  150.       show_warranty ();
  151.       exit (0);
  152.     case 'C':
  153.       show_copying ();
  154.       exit (0);
  155.     case 't':
  156.       formatter = formatter_tex;
  157.       break;
  158.       /* traditional spell options */
  159.       /* ignore these */
  160.     case 'v':        /* don't trust original suffix stripper */
  161.     case 'b':        /* check british spelling */
  162.       break;
  163.     case 'i':        /* don't follow any .so's or .nx's */
  164.       iflag = 1;
  165.       break;
  166.       /* case 'l': */
  167.       /* follow nroff .so's, and .nx's into /usr/lib */
  168.       /* in ispell, this means make a list.  luckily,
  169.              * if the user wants old style, lflag is turned
  170.              * on anyway
  171.              */
  172.  
  173.     case 'x':        /* print stems with '='s */
  174.       (void) fprintf (stderr, "-x is not supported\n");
  175.       exit (1);
  176.  
  177.       /* end of traditional options */
  178.  
  179.     case 'u':
  180.       uflag = 1;
  181.       lflag = 1;
  182.       break;
  183.     case 'h':
  184.       hflag = 1;
  185.       break;
  186.     default:
  187.       usage ();
  188.     case 'D':
  189.       Dflag = 1;
  190.       break;
  191.     case 'E':
  192.       Eflag = 1;
  193.       break;
  194.     case 'p':
  195.       pflag = 1;
  196.       privname = optarg;
  197.       break;
  198.     case 'd':
  199.       dflag = 1;
  200.       dname = optarg;
  201.       break;
  202.     case 'a':
  203.       aflag = 1;
  204.       break;
  205.     case 'l':
  206.       lflag = 1;
  207.       break;
  208.     case 'S':
  209.       Sflag = 1;
  210.       break;
  211.     }
  212.     }
  213.  
  214.   if (optind < argc && argv[optind][0] == '+')
  215.     {
  216.       /* this is for traditional spell - add words in
  217.          * named file to OK list
  218.          */
  219.       (void) p_load (argv[optind] + 1, 0);
  220.       optind++;
  221.     }
  222.  
  223.   if (dflag == 0)
  224.     {
  225.       dname = (char *) getenv ("ISPELL_DICTIONARY");
  226.       if (dname == NULL)
  227.     {
  228.       dname = (char *) xmalloc ((unsigned) strlen (DICT_LIB) + 30);
  229.       (void) strcpy (dname, DICT_LIB);
  230.       (void) strcat (dname, "/ispell.dict");
  231.     }
  232.     }
  233.  
  234.   if (access (dname, 4) < 0)
  235.     {
  236.       (void) fprintf (stderr, "can't read dictionary %s\n", dname);
  237.       exit (1);
  238.     }
  239.  
  240.   if (!Dflag && !Eflag && !Sflag && !aflag && !lflag)
  241.     show_signon ();
  242.  
  243.   if (hash_init (dname) < 0)
  244.     {
  245.       (void) fprintf (stderr, "hash_init failed\n");
  246.       exit (1);
  247.     }
  248.  
  249.   if (hflag)
  250.     {
  251.       prhashchain ();
  252.       exit (0);
  253.     }
  254.  
  255.   if (Dflag)
  256.     {
  257.       hash_awrite (stdout);
  258.       exit (0);
  259.     }
  260.  
  261.   if (Eflag)
  262.     {
  263.       hash_ewrite (stdout);
  264.       exit (0);
  265.     }
  266.  
  267.   if (pflag == 0)
  268.     {
  269.       if ((p = (char *) getenv ("HOME")) != NULL)
  270.     {
  271.       privname = (char *) xmalloc ((unsigned) (strlen (p) + 50));
  272.       (void) strcpy (privname, p);
  273.       (void) strcat (privname, "/ispell.words");
  274.     }
  275.     }
  276.  
  277.   if (privname)
  278.     (void) p_load (privname, 1);
  279.  
  280.   if (Sflag)
  281.     {
  282.       submode ();
  283.     }
  284.   else if (aflag)
  285.     {
  286.       askmode (0);
  287.     }
  288.   else if (uflag)
  289.     {
  290.       spellmode (argc, argv, optind);
  291.       exit (0);
  292.     }
  293.   else if (lflag)
  294.     {
  295.       checkfile (stdin, (FILE *) NULL, (long) 0);
  296.       exit (0);
  297.     }
  298.   else
  299.     {
  300.       /* normal interactive mode */
  301.       if (optind == argc)
  302.     {
  303.       askmode (1);
  304.       exit (0);
  305.     }
  306.       signal (SIGINT, (RETSIGTYPE (*)()) intr);
  307.       terminit ();
  308.       while (optind < argc)
  309.     dofile (argv[optind++]);
  310.  
  311.       if (interaction_flag == 0)
  312.     printf ("No errors detected\r\n");
  313.     }
  314.  
  315.   if (privname)
  316.     (void) p_dump (privname);
  317.  
  318.   done ();
  319.   exit (0);
  320. }
  321.  
  322. extern struct sp_corrections corrections;
  323. static char stdoutbuf[BUFSIZ];
  324.  
  325. void
  326. submode (NOARGS)
  327. {
  328.   char buf[BUFSIZ];
  329.   int i;
  330.   int c;
  331.   int len;
  332.  
  333.   signal (SIGINT, SIG_IGN);
  334.   setbuf (stdin, (char *) NULL);
  335.   setbuf (stdout, stdoutbuf);
  336.   (void) printf ("(1 \"%s\")", VERSION_STRING);
  337.  
  338.   while (1)
  339.     {
  340.     again:
  341.       intr_typed = 0;
  342.       putchar ('=');
  343.       fflush (stdout);
  344.  
  345.       if (fgets (buf, sizeof buf, stdin) == NULL)
  346.     break;
  347.       len = strlen (buf);
  348.       if (len && buf[len - 1] == '\n')
  349.     {
  350.       buf[--len] = 0;
  351.     }
  352.       else
  353.     {
  354.       /* line was too long to hold newline -
  355.              * just return an error without otherwise
  356.              * looking at it
  357.              */
  358.       while (1)
  359.         {
  360.           if ((c = getchar ()) == EOF)
  361.         return;
  362.           if (c == '\n')
  363.         {
  364.           (void) printf ("nil\n");
  365.           goto again;
  366.         }
  367.         }
  368.     }
  369.       if (buf[0] == 0)
  370.     continue;
  371.  
  372.       if (buf[0] == ':')
  373.     {
  374.       if (subcmd (buf) < 0)
  375.         (void) printf ("nil\n");
  376.       else
  377.         (void) printf ("t\n");
  378.       continue;
  379.     }
  380.       if (good (buf, strlen (buf), 0))
  381.     {
  382.       (void) printf ("t\n");
  383.     }
  384.       else
  385.     {
  386.       makepossibilities (buf);
  387.       if (corrections.posbuf[0][0])
  388.         {
  389.           (void) printf ("(");
  390.           for (i = 0; i < 10; i++)
  391.         {
  392.           if (corrections.posbuf[i][0] == 0)
  393.             break;
  394.           (void) printf ("\"%s\" ",
  395.                  corrections.posbuf[i]);
  396.         }
  397.           (void) printf (")\n");
  398.         }
  399.       else
  400.         {
  401.           (void) printf ("nil\n");
  402.         }
  403.     }
  404.     }
  405. }
  406.  
  407. struct cmd
  408. {
  409.   char *name;
  410. #ifdef __STDC__
  411.   int (*func) (char *);
  412. #else
  413.   int (*func) ();
  414. #endif
  415. };
  416.  
  417. extern struct cmd subcmds[];
  418.  
  419. int
  420. subcmd (buf)
  421.   char *buf;
  422. {
  423.   char *p;
  424.   struct cmd *cp;
  425.  
  426.   buf++;            /* skip colon */
  427.   for (p = buf; *p && !isspace (*p); p++)
  428.     ;
  429.   if (*p)
  430.     *p++ = 0;
  431.  
  432.   for (cp = subcmds; cp->name; cp++)
  433.     if (strcmp (cp->name, buf) == 0)
  434.       break;
  435.   if (cp->name == NULL)
  436.     return (-1);
  437.  
  438.   return ((*cp->func) (p));
  439. }
  440.  
  441.  
  442. int
  443. cmd_insert (arg)
  444.      char *arg;
  445. {
  446.   return (p_enter (arg, 1, 1));
  447. }
  448.  
  449.  
  450. int
  451. cmd_accept (arg)
  452.   char *arg;
  453. {
  454.   return (p_enter (arg, 1, 0));
  455. }
  456.  
  457.  
  458. int
  459. cmd_delete (arg)
  460.   char *arg;
  461. {
  462.   return (p_delete (arg));
  463. }
  464.  
  465.  
  466. int
  467. cmd_dump (arg)
  468.   char *arg;
  469. {
  470.   if (privname)
  471.     return (p_dump (privname));
  472.   else
  473.     return (-1);
  474. }
  475.  
  476. /* ARGSUSED */
  477. int
  478. cmd_reload (arg)
  479.   char *arg;
  480. {
  481.   return p_reload ();
  482. }
  483.  
  484.  
  485. int
  486. cmd_file (arg)
  487.   char *arg;
  488. {
  489.   FILE *f;
  490.   long start, end;
  491.   char *p;
  492.  
  493.   for (p = arg; *p && !isspace (*p); p++)
  494.     ;
  495.   if (*p)
  496.     *p++ = 0;
  497.  
  498.   start = 0;
  499.   end = 0;
  500.  
  501.   sscanf (p, "%ld %ld", &start, &end);
  502.  
  503.   if ((f = fopen (arg, "r")) == NULL)
  504.     return -1;
  505.  
  506.   if (fseek (f, start, 0) < 0)
  507.     {
  508.       (void) fclose (f);
  509.       return (-1);
  510.     }
  511.  
  512.   signal (SIGINT, (RETSIGTYPE (*)()) intr);
  513.   checkfile (f, (FILE *) NULL, end);
  514.   signal (SIGINT, SIG_IGN);
  515.  
  516.   (void) fclose (f);
  517.   if (intr_typed)
  518.     {
  519.       intr_typed = 0;
  520.       return (-1);
  521.     }
  522.   else
  523.     {
  524.       return (0);
  525.     }
  526. }
  527.  
  528. /* ARGSUSED */
  529. int
  530. cmd_tex (arg)
  531.   char *arg;
  532. {
  533.   formatter = formatter_tex;
  534.   return (0);
  535. }
  536.  
  537. /* ARGSUSED */
  538. int
  539. cmd_troff (arg)
  540.   char *arg;
  541. {
  542.   formatter = formatter_troff;
  543.   return (0);
  544. }
  545.  
  546. /* ARGUSED */
  547. int
  548. cmd_generic (arg)
  549.   char *arg;
  550. {
  551.   formatter = formatter_generic;
  552.   return (0);
  553. }
  554.  
  555.  
  556. void
  557. spellmode (ac, av, ind)
  558.   char **av;
  559.   int ac, ind;
  560. {
  561.   FILE *f;
  562.  
  563.   sortf = (FILE *) popen ("sort", "w");
  564.   if (sortf == NULL)
  565.     {
  566.       (void) fprintf (stderr, "can't exec 'sort' program\n");
  567.       exit (1);
  568.     }
  569.   if (ac == ind)
  570.     {
  571.       checkfile (stdin, (FILE *) NULL, (long) 0);
  572.     }
  573.   else
  574.     {
  575.       while (ind < ac)
  576.     {
  577.       f = fopen (av[ind], "r");
  578.       if (f == NULL)
  579.         {
  580.           (void) fprintf (stderr, "can't open %s\n", av[ind]);
  581.         }
  582.       else
  583.         {
  584.           checkfile (f, (FILE *) NULL, (long) 0);
  585.           (void) fclose (f);
  586.         }
  587.       ind++;
  588.     }
  589.     }
  590.   (void) pclose (sortf);    /* needed to wait for sort to finish */
  591. }
  592.  
  593.  
  594. struct cmd subcmds[] =
  595. {
  596.   {"insert", cmd_insert},
  597.   {"accept", cmd_accept},
  598.   {"delete", cmd_delete},
  599.   {"dump", cmd_dump},
  600.   {"reload", cmd_reload},
  601.   {"file", cmd_file},
  602.   {"tex", cmd_tex},
  603.   {"troff", cmd_troff},
  604.   {"generic", cmd_generic},
  605.   {NULL}
  606. };
  607.  
  608. #define p(str) printf("%s\n", str)
  609.  
  610. static void
  611. show_signon ()
  612. {
  613.   printf ("%s.\n", VERSION_STRING);
  614.   p ("Copyright (C) 1990, 1993 Free Software Foundation, Inc.");
  615.   p ("Ispell comes with ABSOLUTELY NO WARRANTY; for details run \"ispell -W\"");
  616.   p ("This is free software, and you are welcome to redistribute it");
  617.   p ("under certain conditions; run \"ispell -C\" for details.");
  618. }
  619.  
  620.  
  621. static void
  622. show_copying ()
  623. {
  624.   p ("            GNU GENERAL PUBLIC LICENSE");
  625.   p ("               Version 2, June 1991");
  626.   p ("");
  627.   p (" Copyright (C) 1989, 1991 Free Software Foundation, Inc.");
  628.   p ("                          675 Mass Ave, Cambridge, MA 02139, USA");
  629.   p (" Everyone is permitted to copy and distribute verbatim copies");
  630.   p (" of this license document, but changing it is not allowed.");
  631.   p ("");
  632.   p ("                Preamble");
  633.   p ("");
  634.   p ("  The licenses for most software are designed to take away your");
  635.   p ("freedom to share and change it.  By contrast, the GNU General Public");
  636.   p ("License is intended to guarantee your freedom to share and change free");
  637.   p ("software--to make sure the software is free for all its users.  This");
  638.   p ("General Public License applies to most of the Free Software");
  639.   p ("Foundation's software and to any other program whose authors commit to");
  640.   p ("using it.  (Some other Free Software Foundation software is covered by");
  641.   p ("the GNU Library General Public License instead.)  You can apply it to");
  642.   p ("your programs, too.");
  643.   p ("");
  644.   p ("  When we speak of free software, we are referring to freedom, not");
  645.   p ("price.  Our General Public Licenses are designed to make sure that you");
  646.   p ("have the freedom to distribute copies of free software (and charge for");
  647.   p ("this service if you wish), that you receive source code or can get it");
  648.   p ("if you want it, that you can change the software or use pieces of it");
  649.   p ("in new free programs; and that you know you can do these things.");
  650.   p ("");
  651.   p ("  To protect your rights, we need to make restrictions that forbid");
  652.   p ("anyone to deny you these rights or to ask you to surrender the rights.");
  653.   p ("These restrictions translate to certain responsibilities for you if you");
  654.   p ("distribute copies of the software, or if you modify it.");
  655.   p ("");
  656.   p ("  For example, if you distribute copies of such a program, whether");
  657.   p ("gratis or for a fee, you must give the recipients all the rights that");
  658.   p ("you have.  You must make sure that they, too, receive or can get the");
  659.   p ("source code.  And you must show them these terms so they know their");
  660.   p ("rights.");
  661.   p ("");
  662.   p ("  We protect your rights with two steps: (1) copyright the software, and");
  663.   p ("(2) offer you this license which gives you legal permission to copy,");
  664.   p ("distribute and/or modify the software.");
  665.   p ("");
  666.   p ("  Also, for each author's protection and ours, we want to make certain");
  667.   p ("that everyone understands that there is no warranty for this free");
  668.   p ("software.  If the software is modified by someone else and passed on, we");
  669.   p ("want its recipients to know that what they have is not the original, so");
  670.   p ("that any problems introduced by others will not reflect on the original");
  671.   p ("authors' reputations.");
  672.   p ("");
  673.   p ("  Finally, any free program is threatened constantly by software");
  674.   p ("patents.  We wish to avoid the danger that redistributors of a free");
  675.   p ("program will individually obtain patent licenses, in effect making the");
  676.   p ("program proprietary.  To prevent this, we have made it clear that any");
  677.   p ("patent must be licensed for everyone's free use or not licensed at all.");
  678.   p ("");
  679.   p ("  The precise terms and conditions for copying, distribution and");
  680.   p ("modification follow.");
  681.   p (" ");
  682.   p ("            GNU GENERAL PUBLIC LICENSE");
  683.   p ("   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION");
  684.   p ("");
  685.   p ("  0. This License applies to any program or other work which contains");
  686.   p ("a notice placed by the copyright holder saying it may be distributed");
  687.   p ("under the terms of this General Public License.  The \"Program\", below,");
  688.   p ("refers to any such program or work, and a \"work based on the Program\"");
  689.   p ("means either the Program or any derivative work under copyright law:");
  690.   p ("that is to say, a work containing the Program or a portion of it,");
  691.   p ("either verbatim or with modifications and/or translated into another");
  692.   p ("language.  (Hereinafter, translation is included without limitation in");
  693.   p ("the term \"modification\".)  Each licensee is addressed as \"you\".");
  694.   p ("");
  695.   p ("Activities other than copying, distribution and modification are not");
  696.   p ("covered by this License; they are outside its scope.  The act of");
  697.   p ("running the Program is not restricted, and the output from the Program");
  698.   p ("is covered only if its contents constitute a work based on the");
  699.   p ("Program (independent of having been made by running the Program).");
  700.   p ("Whether that is true depends on what the Program does.");
  701.   p ("");
  702.   p ("  1. You may copy and distribute verbatim copies of the Program's");
  703.   p ("source code as you receive it, in any medium, provided that you");
  704.   p ("conspicuously and appropriately publish on each copy an appropriate");
  705.   p ("copyright notice and disclaimer of warranty; keep intact all the");
  706.   p ("notices that refer to this License and to the absence of any warranty;");
  707.   p ("and give any other recipients of the Program a copy of this License");
  708.   p ("along with the Program.");
  709.   p ("");
  710.   p ("You may charge a fee for the physical act of transferring a copy, and");
  711.   p ("you may at your option offer warranty protection in exchange for a fee.");
  712.   p ("");
  713.   p ("  2. You may modify your copy or copies of the Program or any portion");
  714.   p ("of it, thus forming a work based on the Program, and copy and");
  715.   p ("distribute such modifications or work under the terms of Section 1");
  716.   p ("above, provided that you also meet all of these conditions:");
  717.   p ("");
  718.   p ("    a) You must cause the modified files to carry prominent notices");
  719.   p ("    stating that you changed the files and the date of any change.");
  720.   p ("");
  721.   p ("    b) You must cause any work that you distribute or publish, that in");
  722.   p ("    whole or in part contains or is derived from the Program or any");
  723.   p ("    part thereof, to be licensed as a whole at no charge to all third");
  724.   p ("    parties under the terms of this License.");
  725.   p ("");
  726.   p ("    c) If the modified program normally reads commands interactively");
  727.   p ("    when run, you must cause it, when started running for such");
  728.   p ("    interactive use in the most ordinary way, to print or display an");
  729.   p ("    announcement including an appropriate copyright notice and a");
  730.   p ("    notice that there is no warranty (or else, saying that you provide");
  731.   p ("    a warranty) and that users may redistribute the program under");
  732.   p ("    these conditions, and telling the user how to view a copy of this");
  733.   p ("    License.  (Exception: if the Program itself is interactive but");
  734.   p ("    does not normally print such an announcement, your work based on");
  735.   p ("    the Program is not required to print an announcement.)");
  736.   p (" ");
  737.   p ("These requirements apply to the modified work as a whole.  If");
  738.   p ("identifiable sections of that work are not derived from the Program,");
  739.   p ("and can be reasonably considered independent and separate works in");
  740.   p ("themselves, then this License, and its terms, do not apply to those");
  741.   p ("sections when you distribute them as separate works.  But when you");
  742.   p ("distribute the same sections as part of a whole which is a work based");
  743.   p ("on the Program, the distribution of the whole must be on the terms of");
  744.   p ("this License, whose permissions for other licensees extend to the");
  745.   p ("entire whole, and thus to each and every part regardless of who wrote it.");
  746.   p ("");
  747.   p ("Thus, it is not the intent of this section to claim rights or contest");
  748.   p ("your rights to work written entirely by you; rather, the intent is to");
  749.   p ("exercise the right to control the distribution of derivative or");
  750.   p ("collective works based on the Program.");
  751.   p ("");
  752.   p ("In addition, mere aggregation of another work not based on the Program");
  753.   p ("with the Program (or with a work based on the Program) on a volume of");
  754.   p ("a storage or distribution medium does not bring the other work under");
  755.   p ("the scope of this License.");
  756.   p ("");
  757.   p ("  3. You may copy and distribute the Program (or a work based on it,");
  758.   p ("under Section 2) in object code or executable form under the terms of");
  759.   p ("Sections 1 and 2 above provided that you also do one of the following:");
  760.   p ("");
  761.   p ("    a) Accompany it with the complete corresponding machine-readable");
  762.   p ("    source code, which must be distributed under the terms of Sections");
  763.   p ("    1 and 2 above on a medium customarily used for software interchange; or,");
  764.   p ("");
  765.   p ("    b) Accompany it with a written offer, valid for at least three");
  766.   p ("    years, to give any third party, for a charge no more than your");
  767.   p ("    cost of physically performing source distribution, a complete");
  768.   p ("    machine-readable copy of the corresponding source code, to be");
  769.   p ("    distributed under the terms of Sections 1 and 2 above on a medium");
  770.   p ("    customarily used for software interchange; or,");
  771.   p ("");
  772.   p ("    c) Accompany it with the information you received as to the offer");
  773.   p ("    to distribute corresponding source code.  (This alternative is");
  774.   p ("    allowed only for noncommercial distribution and only if you");
  775.   p ("    received the program in object code or executable form with such");
  776.   p ("    an offer, in accord with Subsection b above.)");
  777.   p ("");
  778.   p ("The source code for a work means the preferred form of the work for");
  779.   p ("making modifications to it.  For an executable work, complete source");
  780.   p ("code means all the source code for all modules it contains, plus any");
  781.   p ("associated interface definition files, plus the scripts used to");
  782.   p ("control compilation and installation of the executable.  However, as a");
  783.   p ("special exception, the source code distributed need not include");
  784.   p ("anything that is normally distributed (in either source or binary");
  785.   p ("form) with the major components (compiler, kernel, and so on) of the");
  786.   p ("operating system on which the executable runs, unless that component");
  787.   p ("itself accompanies the executable.");
  788.   p ("");
  789.   p ("If distribution of executable or object code is made by offering");
  790.   p ("access to copy from a designated place, then offering equivalent");
  791.   p ("access to copy the source code from the same place counts as");
  792.   p ("distribution of the source code, even though third parties are not");
  793.   p ("compelled to copy the source along with the object code.");
  794.   p (" ");
  795.   p ("  4. You may not copy, modify, sublicense, or distribute the Program");
  796.   p ("except as expressly provided under this License.  Any attempt");
  797.   p ("otherwise to copy, modify, sublicense or distribute the Program is");
  798.   p ("void, and will automatically terminate your rights under this License.");
  799.   p ("However, parties who have received copies, or rights, from you under");
  800.   p ("this License will not have their licenses terminated so long as such");
  801.   p ("parties remain in full compliance.");
  802.   p ("");
  803.   p ("  5. You are not required to accept this License, since you have not");
  804.   p ("signed it.  However, nothing else grants you permission to modify or");
  805.   p ("distribute the Program or its derivative works.  These actions are");
  806.   p ("prohibited by law if you do not accept this License.  Therefore, by");
  807.   p ("modifying or distributing the Program (or any work based on the");
  808.   p ("Program), you indicate your acceptance of this License to do so, and");
  809.   p ("all its terms and conditions for copying, distributing or modifying");
  810.   p ("the Program or works based on it.");
  811.   p ("");
  812.   p ("  6. Each time you redistribute the Program (or any work based on the");
  813.   p ("Program), the recipient automatically receives a license from the");
  814.   p ("original licensor to copy, distribute or modify the Program subject to");
  815.   p ("these terms and conditions.  You may not impose any further");
  816.   p ("restrictions on the recipients' exercise of the rights granted herein.");
  817.   p ("You are not responsible for enforcing compliance by third parties to");
  818.   p ("this License.");
  819.   p ("");
  820.   p ("  7. If, as a consequence of a court judgment or allegation of patent");
  821.   p ("infringement or for any other reason (not limited to patent issues),");
  822.   p ("conditions are imposed on you (whether by court order, agreement or");
  823.   p ("otherwise) that contradict the conditions of this License, they do not");
  824.   p ("excuse you from the conditions of this License.  If you cannot");
  825.   p ("distribute so as to satisfy simultaneously your obligations under this");
  826.   p ("License and any other pertinent obligations, then as a consequence you");
  827.   p ("may not distribute the Program at all.  For example, if a patent");
  828.   p ("license would not permit royalty-free redistribution of the Program by");
  829.   p ("all those who receive copies directly or indirectly through you, then");
  830.   p ("the only way you could satisfy both it and this License would be to");
  831.   p ("refrain entirely from distribution of the Program.");
  832.   p ("");
  833.   p ("If any portion of this section is held invalid or unenforceable under");
  834.   p ("any particular circumstance, the balance of the section is intended to");
  835.   p ("apply and the section as a whole is intended to apply in other");
  836.   p ("circumstances.");
  837.   p ("");
  838.   p ("It is not the purpose of this section to induce you to infringe any");
  839.   p ("patents or other property right claims or to contest validity of any");
  840.   p ("such claims; this section has the sole purpose of protecting the");
  841.   p ("integrity of the free software distribution system, which is");
  842.   p ("implemented by public license practices.  Many people have made");
  843.   p ("generous contributions to the wide range of software distributed");
  844.   p ("through that system in reliance on consistent application of that");
  845.   p ("system; it is up to the author/donor to decide if he or she is willing");
  846.   p ("to distribute software through any other system and a licensee cannot");
  847.   p ("impose that choice.");
  848.   p ("");
  849.   p ("This section is intended to make thoroughly clear what is believed to");
  850.   p ("be a consequence of the rest of this License.");
  851.   p (" ");
  852.   p ("  8. If the distribution and/or use of the Program is restricted in");
  853.   p ("certain countries either by patents or by copyrighted interfaces, the");
  854.   p ("original copyright holder who places the Program under this License");
  855.   p ("may add an explicit geographical distribution limitation excluding");
  856.   p ("those countries, so that distribution is permitted only in or among");
  857.   p ("countries not thus excluded.  In such case, this License incorporates");
  858.   p ("the limitation as if written in the body of this License.");
  859.   p ("");
  860.   p ("  9. The Free Software Foundation may publish revised and/or new versions");
  861.   p ("of the General Public License from time to time.  Such new versions will");
  862.   p ("be similar in spirit to the present version, but may differ in detail to");
  863.   p ("address new problems or concerns.");
  864.   p ("");
  865.   p ("Each version is given a distinguishing version number.  If the Program");
  866.   p ("specifies a version number of this License which applies to it and \"any");
  867.   p ("later version\", you have the option of following the terms and conditions");
  868.   p ("either of that version or of any later version published by the Free");
  869.   p ("Software Foundation.  If the Program does not specify a version number of");
  870.   p ("this License, you may choose any version ever published by the Free Software");
  871.   p ("Foundation.");
  872.   p ("");
  873.   p ("  10. If you wish to incorporate parts of the Program into other free");
  874.   p ("programs whose distribution conditions are different, write to the author");
  875.   p ("to ask for permission.  For software which is copyrighted by the Free");
  876.   p ("Software Foundation, write to the Free Software Foundation; we sometimes");
  877.   p ("make exceptions for this.  Our decision will be guided by the two goals");
  878.   p ("of preserving the free status of all derivatives of our free software and");
  879.   p ("of promoting the sharing and reuse of software generally.");
  880.   p ("");
  881. }
  882.  
  883.  
  884. static void
  885. show_warranty ()
  886. {
  887.   p ("                NO WARRANTY");
  888.   p ("");
  889.   p ("  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY");
  890.   p ("FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN");
  891.   p ("OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES");
  892.   p ("PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED");
  893.   p ("OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF");
  894.   p ("MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS");
  895.   p ("TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE");
  896.   p ("PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,");
  897.   p ("REPAIR OR CORRECTION.");
  898.   p ("");
  899.   p ("  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING");
  900.   p ("WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR");
  901.   p ("REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,");
  902.   p ("INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING");
  903.   p ("OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED");
  904.   p ("TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY");
  905.   p ("YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER");
  906.   p ("PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE");
  907.   p ("POSSIBILITY OF SUCH DAMAGES.");
  908.   p ("");
  909. }
  910.